<?
require_once(_APPLICATION."/service/model_common.php");
/// @brief Define Core class 
/// @author ggugi
/// @date 2012-07-03
/// @params 
/// @return 
class member_model_set extends model_common
{
	/**
	 * @brief main class 
	 * @date 2012-07-03
	 **/
	public function insertMemberInfo($aMemberData)
	{
        $this->mysqli->doExecute(sprintf(
            "insert into user set 
                Id  = '%s',
                Password    = password('%s'),
                IsFacebookId    = '%s',
                update_at       = %s,
                create_at        = %s
            ",
            $aMemberData['Id'],
            $aMemberData['Password'],
            $aMemberData['IsFacebookId'],
            time(),
            time()
            )
        ); 

        return $this->mysqli->doQuery(sprintf(
            "select last_insert_id()"
            )
        );
	}

	/**
	 * @brief main class 
	 * @date 2012-07-03
	 **/
	public function insertDeviceInfo($aDeviceData)
	{
        $this->mysqli->doExecute(sprintf(
            "insert into device set 
                User_Idx  = last_insert_id(),
                DeviceToken = '%s',
                DeviceType  = '%s',
                update_at       = %s,
                create_at        = %s
            ",
            $aDeviceData['DeviceToken'],
            $aDeviceData['DeviceType'],
            time(),
            time()
            )
        ); 
	}

	/**
	 * @brief 회원정보를 갱신한다.
	 * @date 2012-07-03
	 **/
	public function updateMemberInfo($aMemberData)
	{
        $this->mysqli->doExecute(sprintf(
            "update user set 
                Password    = password('%s'),
                Nickname    = '%s',
                Message     = '%s',
                Photo       = '%s',
                update_at       = %s
             where
                Idx = '%d'
            ",
            $aMemberData['Password'],
            $aMemberData['Nickname'],
            $aMemberData['Message'],
            $aMemberData['Photo'],
            time(),
            $aMemberData['SessionId']
            )
        ); 

        return $this->mysqli->doQuery(sprintf(
            "select last_insert_id()"
            )
        );
	}




}
